home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Utilities Experience
/
The Utilities Experience - Volume 1.iso
/
software
/
comms
/
voodoo
/
contrib
/
newobtaingirport
/
newobtaingirport.doc
< prev
Wrap
Text File
|
1995-01-29
|
3KB
|
64 lines
NewObtainGIRPort 1.0
Written by Osma Ahvenlampi, Public Domain
This program comes with NO WARRANTY. Use at your own risk.
BACKGROUND
NewObtainGIRPort is a simple patch to the Intuition ObtainGIRPort() call,
making certain BOOPSI gadgets and hacks such as Magic Menu and CycleToMenu
co-exist peacefully.
After using textfield.gadget, by Mark Thomas, in a program of mine, the
tendency of it to go into a deadlock situation with Magic Menu became
unbearable. I was pointed to a patch for this, called PatchOGR, also by
Mark Thomas. However, this program had even MORE problems, which I will
outline below, so I wrote my own.
USAGE
To install the patch, run NewObtainGIRPort from CLI. To keep the size
to the minimum, it has no Workbench startup code.
You should add the line "Run <>NIL: NewObtainGIRPort <>NIL:" to your
User-Startup, if you want to use this patch.
After installing the patch, NewObtainGIRPort will stick around,
waiting for a CTRL-C signal, on which it will (if possible) remove the
patch and exit. If another program has patched over NewObtainGIRPort,
it will flash the screen and refuse to quit.
EXPLANATION
This patch adds a safety check in the ObtainGIRPort() call, by
checking whether the layer of the GadgetInfo structure is already
locked. If it is, the patch will simply return NULL.
The version of this patch by Mark Thomas had two major problems.
First, it did not check whether the GadgetInfo had a valid layer, but
simply called AttemptLockLayerRom() with a NULL layer. This is
illegal. Secondly, it subsequently called ObtainGIRPort() while having
itself locked the layer of the gadget. This is even more illegal.
My version does not do either of these ;). This version leaves a
minimal window for a deadlock situation open, as the GadgetInfo layer
is free'd before obtaining the RastPort of the gadget. The probability
of another task locking the layer in between these two operations is,
however, so small, that I did not think it warrants enclosing the
patch inside Forbid()/Permit(). If you wish to add that, the change in
the source is trivial.
Thanks to Greg Block in helping to find the problem in PatchOGR.
AUTHOR
Email: <Osma.Ahvenlampi@hut.fi>
Snailmail: Osma Ahvenlampi
Rekipellontie 2 F 55
00940 Helsinki
Finland
I wouldn't mind a postcard from you if you think this is a useful
program...